#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <math.h>
#include <string.h>
int q = 0;
void yzc(char w, int x1, int x2, int lon)
{
	int sum;
	if (w == 'a')
		q = 1;
	if (w == 'b')
		q = 2;
	if (w == 'c')
		q = 3;
	if (q == 1)
	{
		sum = x1 + x2;
		if (sum == 0)
			lon++;
		if (sum < 0)
			lon++;
		while (sum != 0)
		{
			lon++;
			sum = sum / 10;
		}
		printf("%d+%d=%d\n%d\n", x1, x2, x1 + x2, lon + 2);
	}
	if (q == 2)
	{
		sum = x1 - x2;
		if (sum < 0)
			lon++;
		else if (sum == 0)
			lon++;
		while (sum != 0)
		{
			lon++;
			sum = sum / 10;
		}
		printf("%d-%d=%d\n%d\n", x1, x2, x1 - x2, lon + 2);
	}
	if (q == 3)
	{
		sum = x1 * x2;
		if (sum == 0)
			lon++;
		if (sum < 0)
			lon++;
		while (sum != 0)
		{
			lon++;
			sum = sum / 10;
		}
		printf("%d*%d=%d\n%d\n", x1, x2, x1 * x2, lon + 2);
	}
}
int main()
{
	int i;
	scanf("%d", &i);
	scanf("\n");
	char arr[100][100] = { '\0' };
	for (int w = 0; w < i; w++)
	{
		fgets(arr[w], 100, stdin);
	}
	for (int w = 0; w < i; w++)
	{
		int x1 = 0, x2 = -1, tmp1 = 0, tmp2 = -2, lon = 0, sum = 0;
		for (int e = 0;; e++)
		{
			if (arr[w][e] == '\0')
				break;
			if (e == 0 && arr[w][0] >= 'a' && arr[w][0] <= 'c')
			{
				e = 1; continue;
			}
			if (arr[w][e] != ' ' && x2 < 0)
			{
				x1 = x1 * 10 + (arr[w][e] - 48); tmp1 = e; lon++;
			}
			if (arr[w][e] == ' ' && tmp2 == -2)
			{
				tmp2 = e;
				x2 = 0;
				continue;
			}
			if (tmp2 == tmp1 + 1 && arr[w][e] >= '0' && arr[w][e] <= '9')
			{
				x2 = x2 * 10 + (arr[w][e] - 48); lon++;
			}
		}

		yzc(arr[w][0], x1, x2, lon);
	}
	return 0;
}

